<template>
    <div class="demo-collapse">
        <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="问题描述" name="des">
                <div class="detail">
                    <img class="image" src="../../../../../assets/快速排序/快速排序1.jpg">
                    <div class="detail-text">
                        <div class="text">
                            快速排序（Quicksort）由英国计算机科学家Tony Hoare于1959年发明，是一种经典的排序算法，被广泛应用于计算机科学领域。
                            快速排序（Quick Sort）是一种常见的基于比较的排序算法，也是最常用的排序算法之一。
                        </div>
                        <el-table :data="tableData" border style="width: 99%;">
                            <el-table-column prop="name" label="排序方法"  />
                            <el-table-column prop="best" label="最好时间复杂度"  />
                            <el-table-column prop="average" label="平均时间复杂度"  />
                            <el-table-column prop="badest" label="最坏时间复杂度"  />
                            <el-table-column prop="spatial" label="空间复杂度"  />
                            <el-table-column prop="stability" label="稳定性"  />
                        </el-table>
                    </div>
                </div>
            </el-collapse-item>
            <el-collapse-item title="相关研究" name="3">
                <ul>
                    <li v-for="item in thesisData" :key="item.title">
                        <a :href="item.link" target="_blank">
                            <div class="thesis">
                                <img class="thesis-cover" src="../../../../../icons//thesis.svg" alt="">
                                <div class="thesis-title">
                                    {{ item.title }}
                                </div>
                                <div class="thesis-author">
                                    <span>作者：</span>{{ item.author }}
                                </div>
                                <div class="thesis-time">
                                    <span>时间：</span>{{ item.time }}
                                </div>
                                <div class="thesis-source">
                                    <span>来源：</span>{{ item.source }}
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </el-collapse-item>
            <el-collapse-item title="应用领域" name="4">
                <div class="detail">
                    <img class="use" src="../../../../../assets/快速排序/快速排序2.jpg" alt="">
                    <div class="text">
                        快速排序时间复杂度为O(nlogn)，是目前基于比较的内部排序中被认为最好的方法，当数据过大且数据杂乱无章时，则适合采用快速排序
                    </div>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const activeNames = ref(['1'])
const handleChange = (val: string[]) => {
    console.log(val)
}

// 相关研究部分
const thesisData = [
    {
        title: "快速排序算法研究",
        author: "霍红卫，许进",
        time: "2002年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=dd0a2b99a55781f7a7a2b0df8f6f6dc1&site=xueshu_se",
    },
    {
        title: "超快速排序算法",
        author: "周建钦",
        time: "2006年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=3467584c4c920b39608ffd766ecc1cda&site=xueshu_se",
    },
    {
        title: "基于快速排序的改进算法较",
        author: "郭晶旭",
        time: "2009年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=41d33542edfb850e068cb6045b2c01c0&site=xueshu_se",
    },

]

// 复杂度表格描述
const tableData = [
    {
        name: '快速排序',
        best:'O(n * log(n))',
        average:'O(n * log(n))',
        badest:'O(n^2)',
        spatial:'O(log(n)) ~ O(n)',
        stability:'不稳定',
    },
]
</script>

<style scoped lang="scss">
* {
    list-style: none;
}

.image {
    width: 290px;
    border-radius: 10px;
    margin-right: 10px;
}

a {
    text-decoration: none;
    /* 去除默认的下划线 */
    outline: none;
    /* 去除旧版浏览器的点击后的外虚线框 */
    color: #000;
    /* 去除默认的颜色和点击后变化的颜色 */
}

.detail {
    display: flex;
    justify-content: center;
    align-items: end;

    .detail-box {
        display: flex;
        flex-direction: column;
    }
    .text {
        margin-left: 10px;
        margin-bottom: 10px;
        cursor: default;
    }

    .use {
        width: 240px;
        height: 150px;
        border-radius: 10px;
    }
}

// 相关研究部分
.thesis {
    width: 98%;
    position: relative;
    left: 20px;
    margin-bottom: 10px;
    font-weight: normal;
    background: #F5F5F5;
    border-radius: 10px;
    transition: all 0.2s linear;

    .thesis-title {
        position: absolute;
        top: 0;
        left: 5px;
    }

    .thesis-author {
        position: absolute;
        top: 25px;
        left: 120px;
    }

    .thesis-time {
        position: absolute;
        top: 45px;
        left: 120px;
    }

    .thesis-source {
        position: absolute;
        top: 65px;
        left: 120px;
    }

    &:hover {
        cursor: pointer;
        transform: translateX(-15px);
    }
}</style>